package src.main.BehavioralPatterns.Iterator;

import java.util.ArrayList;
import java.util.List;

// 具体集合：书架
public class BookShelf implements BookCollection {
    private List<Book> books = new ArrayList<>();

    // 添加书籍到书架
    public void addBook(Book book) {
        books.add(book);
    }

    // 实现创建迭代器方法：返回BookShelfIterator实例
    @Override
    public Iterator<Book> createIterator() {
        return new BookShelfIterator(books);
    }

    // 获取书籍数量
    public int size() {
        return books.size();
    }
}
